<template>
  <div class="biddingManage">
    <el-empty v-if="!noData"
              description="您未有投标申请记录.......">
      <el-link type="primary" @click="toMoreInformation">查看更多招标信息</el-link>
    </el-empty>

    <el-table
        :data="biddingTable"
        style="width: 100%"
        height="600"
        highlight-current-row
        v-if="noData"
        stripe
    >
      <el-table-column
          label="序号"
          type="index">
        <template slot-scope="scope">
          {{scope.$index+1}}
        </template>
      </el-table-column>
      <el-table-column
          prop="tender.tenderTitle"
          label="招标信息"
      >
        <template slot-scope="scope">
          <el-link @click="toTenderDetail(scope.row.tender.tenderId)" target="_blank">{{scope.row.tender.tenderTitle}}</el-link>
        </template>

      </el-table-column>

      <el-table-column
          prop="biddingTime"
          label="投标时间"
          sortable>
        <template slot-scope="scope">
          {{shortTime(scope.row.biddingTime)}}
        </template>
      </el-table-column>

      <el-table-column
          prop="biddingPrice"
          label="投标价格"
      >
      </el-table-column>

      <el-table-column
          prop="biddingStatus"
          label="投标状态"
      >
        <template slot-scope="scope">
          <span v-if="scope.row.biddingStatus == 1"><el-tag type="success" size="small" color="">中标</el-tag></span>
          <span v-else-if="scope.row.biddingStatus ==2 "><el-tag type="danger" size="small" color="">落选</el-tag></span>
          <span v-else><el-tag type="info" size="small" color="">待处理</el-tag></span>
        </template>
      </el-table-column>

    </el-table>
  </div>
</template>

<script>
import {shortTime} from "../../../../utils/timeFormat";
import {getBiddingByUserId} from "@/api/allApi";

export default {
  name: "BiddingManage",
  data() {
    return {
      biddingTable:[],
      noData:false,
      user:'',
    }
  },
  created() {
    this.user = JSON.parse(window.localStorage.getItem('access-user'))
  },
  methods: {
    shortTime,

    getBiddingByUserId(){
      getBiddingByUserId(this.user.userId).then(res=>{
        if (res.data.data.length>0){
          this.noData = true
        }
        this.biddingTable = res.data.data
      })
    },
    toTenderDetail(tenderId) {
      this.$router.push({
        path: "/userLayout/binddingParticulars/"+tenderId,
      });
    },
    toMoreInformation() {
      this.$router.push({
        path: "/userLayout/moreInformation",
      });
    },
  },
  mounted() {
    this.getBiddingByUserId()

  }

}
</script>

<style scoped>

</style>